import {StatusData} from "../../coreModule/data/BaseData";
import {DataOccasion, field, occasion} from "../../coreModule/data/DataLoader";
import {DateUtils} from "../../../utils/DateUtils";
import {TaskType} from "../../taskModule/data/Task";

export enum WithdrawStatus {
  Applying,Passed,NotPassed,Canceled
}

export class Withdraw extends StatusData<WithdrawStatus> {

  @field(String)
  public userId: string; // 用户
  @field(Number)
  public value: number; // 以分为单位
  @field(Number)
  public balance: number; // 以分为单位
  @field(String)
  public alipay?: string;
  @field(String)
  public bankcard?: string;
  @field(Number)
  public createdAt: number;

  // region 额外信息

  @field(String)
  @occasion(DataOccasion.Extra)
  public timeStr: string;
  @field(String)
  @occasion(DataOccasion.Extra)
  priceStr: string
  @field(String)
  @occasion(DataOccasion.Extra)
  statusStr: string

  public refresh() {
    this.timeStr = DateUtils.time2Str(this.createdAt);
    this.priceStr = (this.value / 100).toFixed(2);
    this.statusStr = ["申请中", "审核通过", "审核未通过", "已取消"][this.status]
  }

  // endregion
}
